<%@ include file="/taglibs.jsp"%>
<jsp:directive.page import="java.util.Random"/>
<jsp:directive.page import="java.util.Date"/>
<%if(session.getAttribute("randFormID") == null){
	Random gen = new Random(new Date().getTime());
	session.setAttribute("randFormID", gen.nextInt() + "");
}%>


<title>Winter War Administration ~ Edit Event</title>

<p>Please fill out your information</p>

<html:form action="/wwadmin/event">
	<input type="hidden" name="method" value="save"/>
	<input type="hidden" name="formID" value="<%=session.getAttribute("randFormID") %>"/>
	<input type="hidden" name="event.conID" value="${conID }"/>
	<html:hidden property="event.eventID"/>
	<input type="hidden" name="user.level" value="1"/>
	<html:select property="event.userID" onchange="if(this.value == ''){ document.getElementById('userPortion').style.display = 'block';} else {document.getElementById('userPortion').style.display='none';}">
		<html:option value="">New User...</html:option>
		<c:forEach var="user" items="${users}" varStatus="status">
			<html:option value="${user.userID}">${user.lastName}, ${user.firstName}</html:option>
		</c:forEach>
	</html:select><br/>
	<c:choose>
		<c:when test="${userID != '0' }">
			${event.userID}
			${user.firstName } ${user.lastName }<br/>
			${user.address1 }<br/>
			${user.city }, ${user.state } ${user.zipCode }<br/>
			${user.email } ${user.phoneNumber }<br/><br/>
		</c:when>
	</c:choose>
	<table id="userPortion" <c:choose><c:when  test="${userID != '0' }">style="display:none"</c:when></c:choose>>
		<tr>
			<th><bean:message key="user.firstName"/>: </th>
			<td><html:text property="user.firstName"/></td>
			<th><bean:message key="user.phoneNumber"/>: </th>
			<td><html:text property="user.phoneNumber"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.lastName"/>: </th>
			<td><html:text property="user.lastName"/></td>
			<th><bean:message key="user.email"/>: </th>
			<td><html:text property="user.email"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.address1"/>: </th>
			<td><html:text property="user.address1"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.address2"/>: </th>
			<td><html:text property="user.address2"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.city"/>: </th>
			<td><html:text property="user.city"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.state"/>: </th>
			<td><html:text property="user.state"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.zipCode"/>: </th>
			<td><html:text property="user.zipCode"/></td>
		</tr>
	</table>
	<hr/>
	<table>
		<tr>
			<th><bean:message key="event.eventName"/>: </th>
			<td><html:text property="event.eventName"/></td>
			<th><bean:message key="event.rules"/>: </th>
			<td><html:text property="event.rules"/></td>
		</tr>
		<tr>
			<th><bean:message key="event.eventCode"/>: </th>
			<td><html:text property="event.eventCode"/></td>
			<th><bean:message key="event.tableName"/>: </th>
			<td><html:select property="event.tableID">
					<html:option value="">None Yet...</html:option>
					<c:forEach var="table" items="${tables }">
							<html:option value="${table.tableID}">${table.tableName}</html:option>
					</c:forEach>
				</html:select>
			</td>
		</tr>

		<tr>
			<th><bean:message key="event.eventDesc"/>: </th>
			<td colspan="3"><html:textarea property="event.eventDesc"/></td>
		</tr>
		<tr>
			<th><bean:message key="event.totalSeats"/>: </th>
			<td><html:text property="event.totalSeats"/></td>
			<th><bean:message key="event.slots"/>: </th>
			<td><html:text property="event.slots"/></td>
		</tr>
		<tr>
			<th><bean:message key="event.slot"/>: </th>
			<td><html:select property="event.slotID">
				<c:forEach var="slot" items="${slots}" varStatus="status">
					<html:option value="${slot.slotID}">${slot.slotName}, ${slot.startDateDate}, ${slot.startDateHour} ${slot.startDateAMPM }</html:option>
				</c:forEach>
				</html:select>
			</td>
			<th><bean:message key="event.altSlot"/>: </th>
			<td><html:select property="event.altSlotID">
				<html:option value=""></html:option>
				<c:forEach var="slot" items="${slots}" varStatus="status">
					<html:option value="${slot.slotID}">${slot.slotName}, ${slot.startDateDate}, ${slot.startDateHour} ${slot.startDateAMPM }</html:option>
				</c:forEach>
				</html:select>
			</td>
		</tr>
		<tr>
			<th><bean:message key="event.playerExperience"/>: </th>
			<td><html:select property="event.playerExperience">
					<html:option value="1"><bean:message key="event.experience1"/></html:option>
					<html:option value="2"><bean:message key="event.experience2"/></html:option>
					<html:option value="3"><bean:message key="event.experience3"/></html:option>
					<html:option value="4"><bean:message key="event.experience4"/></html:option>
					<html:option value="5"><bean:message key="event.experience5"/></html:option>
					<html:option value="6"><bean:message key="event.experience6"/></html:option>
				</html:select>
			</td>
			<th><bean:message key="event.tablesRequired"/>: </th>
			<td><html:text property="event.tablesRequired"/></td>
		</tr>
		<tr>
			<th><bean:message key="event.status"/></th>
			<td><html:radio property="event.status" value="1">Submitted</html:radio><br/><html:radio property="event.status" value="2">Review</html:radio><br/><html:radio property="event.status" value="3">Approved</html:radio><br/><html:radio property="event.status" value="4">Rejected</html:radio></td>
			<th><bean:message key="event.eventType"/></th>
			<td>
				<html:select property="event.eventType">
					<html:option value="1">Board Game</html:option>
					<html:option value="2">Card Game</html:option>
					<html:option value="3">Miniatures Event</html:option>
					<html:option value="4">Role Playing Event</html:option>
					<html:option value="5">ASL Event</html:option>
					<html:option value="6">RPGA Event</html:option>
				</html:select>
			</td>
		</tr>
		<tr>
			<th>
				<bean:message key="event.additionalJudges"/>
			</th>
			<td>
				<html:text property="event.additionalJudges"/>
			</td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td><html:submit>Save</html:submit></td>
		</tr>
	</table>
	<h2>Players</h2>
	<c:forEach var="player" items="${event.players }">
			${player.firstName } ${player.lastName }<br/>
	</c:forEach>
</html:form>